//
//  NewsDetial.swift
//  知乎日报Demo
//
//  Created by Ann on 2017/10/19.
//  Copyright © 2017年 Ann. All rights reserved.
//

import UIKit

class NewsDetial: NSObject {
    
    /// 主要的内容
    var body: String?
    
    /// 图片版权
    var image_source: String?
    
    /// 标题
    var title: String?
    
    /// 图片的URL
    var image: String?
    
    /// 分享地址
    var share_url: String?
    
    /// 网页js的url地址
    var js: [String]?
    
    /// 推荐者的头像
    var recommenders: [String]?
    
    /// 无用
    var ga_prefix: Int = 0
    
    /// 新闻类型  内部新闻是0  外联是1
    var type: Int = 0
    
    /// 新闻的ID
    var id: Int = 0
    
    /// 网页的css的url地址
    var css: [String]?
    
    ///栏目对象
    var section: Section?
    
    init(dict:[String:AnyObject]) {
        
        super.init()
        
        self.setValuesForKeys(dict)
    }
    
    
    override func setValue(_ value: Any?, forKey key: String) {
        
        if key == "section" {
            section = Section(dict: value as! [String : AnyObject])
            return
        }
        super.setValue(value, forKey: key)
        
        
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
    override var description: String {
        let  keys = ["body","image_source","title","image","share_url","js","recommenders","ga_prefix","type","id","css","section"]
        return dictionaryWithValues(forKeys: keys).description
        
    }
    
}

class Section :NSObject {
    
    var thumbnail: String?
    var id: Int = 0
    var name: String?
    
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    override var description: String {
        
        let keys = ["thumbnail","name","id"]
        return dictionaryWithValues(forKeys: keys).description
    }
    
    
}
class NewsExtra:NSObject{
    var long_comments : Int = 0
    var popularity : Int = 0
    var short_comments : Int = 0
    var comments : Int = 0
    
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    override var description: String {
        
        let keys = ["long_comments","popularity","short_comments","comments"]
        return dictionaryWithValues(forKeys: keys).description
    }
    
}
